package com.imy.lua.lib;

import android.content.pm.PackageInfo;
import android.view.KeyEvent;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;

import com.immomo.mls.MLSBuilder;
import com.immomo.mls.wrapper.Register;

import com.imy.lua.lib.app.UDApp;
import com.imy.lua.lib.base64.UDBase64;
import com.imy.lua.lib.constant.GestureMode;
import com.imy.lua.lib.constant.Orientation;
import com.imy.lua.lib.device.UDDevice;
import com.imy.lua.lib.environment.UDEnvironment;
import com.imy.lua.lib.file.UDFileUtils;
import com.imy.lua.lib.gesture.UDGesture;
import com.imy.lua.lib.image.UDImage;
import com.imy.lua.lib.log.UDLog;
import com.imy.lua.lib.node.UDRule;
import com.imy.lua.lib.screen.UDScreen;
import com.imy.lua.lib.thread.UDScriptThread;
import com.imy.lua.lib.thread.UDThread;
import com.imy.lua.lib.ui.UIHandler;
import com.imy.lua.udmapping.event.UDKeyEvent;
import com.imy.lua.udmapping.node.UDAccessibilityEvent;
import com.imy.lua.udmapping.node.UDNodeInfo;
import com.imy.lua.udmapping.pinfo.UDPackageInfo;
import com.imy.lua.udmapping.point.UDLocationPoint;

public class RegisterManger {
    /**
     * 注册UD 非View类型
     *
     * @return
     */
    public static Register.UDHolder[] regUD() {
        return new Register.UDHolder[]{
                Register.newUDHolder(UDPackageInfo.LUA_CLASS_NAME, UDPackageInfo.class, false, UDPackageInfo.methods),
                Register.newUDHolder(UDNodeInfo.LUA_CLASS_NAME, UDNodeInfo.class, false, UDNodeInfo.methods),
                Register.newUDHolder(UDAccessibilityEvent.LUA_CLASS_NAME, UDAccessibilityEvent.class, false, UDAccessibilityEvent.methods),
                Register.newUDHolder(UDKeyEvent.LUA_CLASS_NAME, UDKeyEvent.class, false, UDKeyEvent.methods),
                Register.newUDHolder(UDLocationPoint.LUA_CLASS_NAME,UDLocationPoint.class,false,UDLocationPoint.methods),
                Register.newUDHolderWithLuaClass(UDScriptThread.LUA_CLASS_NAME, UDScriptThread.class, false),
                Register.newUDHolderWithLuaClass(UDThread.LUA_CLASS_NAME, UDThread.class, false),
                Register.newUDHolderWithLuaClass(UDDevice.LUA_CLASS_NAME, UDDevice.class, false),
                Register.newUDHolderWithLuaClass(UDGesture.LUA_CLASS_NAME, UDGesture.class, false),
                Register.newUDHolderWithLuaClass(UDApp.LUA_CLASS_NAME, UDApp.class, false),
                Register.newUDHolderWithLuaClass(UDRule.LUA_CLASS_NAME, UDRule.class, false),
        };
    }

    /**
     * 注册静态类
     *
     * @return
     */
    public static Register.SHolder[] registerStaticClass() {
        return new Register.SHolder[]{
                /// 第一种，类中含有LuaClass注解
                Register.newSHolderWithLuaClass(UDBase64.LUA_CLASS_NAME, UDBase64.class),
                Register.newSHolderWithLuaClass(UIHandler.LUA_CLASS_NAME, UIHandler.class),
                Register.newSHolderWithLuaClass(UDEnvironment.LUA_CLASS_NAME, UDEnvironment.class),
                Register.newSHolderWithLuaClass(UDFileUtils.LUA_CLASS_NAME,UDFileUtils.class)
        /// 第二种，类中不含有LuaClass注解
        //                Register.newSHolder(LTTypeUtils.LUA_CLASS_NAME, LTTypeUtils.class, LTTypeUtils.methods),
    };
    }

    /**
     * 注册单例的UD
     *
     * @return
     */
    public static MLSBuilder.SIHolder[] registerSingleInstance() {
        return new MLSBuilder.SIHolder[]{
                new MLSBuilder.SIHolder(UDLog.LUA_CLASS_NAME, UDLog.class),
                new MLSBuilder.SIHolder(UDScreen.LUA_CLASS_NAME, UDScreen.class),
                new MLSBuilder.SIHolder(UDImage.LUA_CLASS_NAME,UDImage.class),

        };
    }

    /**
     * 注册转换器 需要把java 转换lua的 都需要先通过转换器注册
     *
     * @return
     */
    public static MLSBuilder.CHolder[] registerCovert() {
        return new MLSBuilder.CHolder[]{
                new MLSBuilder.CHolder(PackageInfo.class, UDPackageInfo.L, true),
                new MLSBuilder.CHolder(AccessibilityNodeInfo.class, UDNodeInfo.L, true),
                new MLSBuilder.CHolder(AccessibilityEvent.class, UDAccessibilityEvent.L, true),
                new MLSBuilder.CHolder(KeyEvent.class, UDKeyEvent.L, true),
                new MLSBuilder.CHolder(UDLocationPoint.class, UDLocationPoint.L,true),

                /// end
        };
    }

    /**
     * 注册一些映射函数
     *
     * @return
     */
    public static Class[] registerConstants() {
        return new Class[]{
                GestureMode.class,
                com.imy.lua.lib.constant.KeyEvent.class,
                Orientation.class,
        };
    }

}
